home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Fields_rotate.ieb 1.11, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 1/2 1997 Stockholm/Sweden ** ** Individually rotate small fields in primary image. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' Xfield=64 ; Yfield=64 ; Angle=45 if command ~= '' then parse var command Xfield Yfield Angle '#'CalcType 'IE_TO_FRONT' form = 'FORM "Fields Rotate" " OK | Cancel "', ' INTEGER,"Field size width (X)",2,1024,'Xfield',SLIDER', ' INTEGER,"Field size height (Y)",2,1024,'Yfield',SLIDER', ' INTEGER,"Rotation angle",-3600,3600,'Angle',SLIDER' if command = '' then do form = form||' CYCLE,"Type:","Best|Fast",0' form parse var result ok Xfield Yfield Angle CalcType . if ok = 0 then return '<ERROR>' if CalcType=0 then CalcType='BEST' else CalcType = 'FAST' end else do form parse var result ok Xfield Yfield Angle . if ok = 0 then return '<ERROR>' CalcType = 'none' end back = Xfield Yfield Angle '#'CalcType return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' parse var options Xfield Yfield Angle '#'CalcType . 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result 'PROJECT_INFO' LoadImage 'WIDTH' /* image width */ IW = RESULT 'PROJECT_INFO' LoadImage 'HEIGHT' /* image height */ IH = RESULT do until ((Angle < 360)&(Angle >= 0)) if Angle > 359 then Angle = Angle - 360 if Angle < 0 then Angle = Angle + 360 end 'BRIGHTNESS' LoadImage '-255' BackImage = Result do y = 1 to trunc(IH/Yfield)+1 do x = 1 to trunc(Xfield)+1 CropX = trunc((x-1)*Xfield) CropY = trunc((y-1)*Yfield) CropXX = trunc(x*Xfield)-1 CropYY = trunc(y*Yfield)-1 if CropXX >= IW then CropXX = IW-1 if CropYY >= IH then CropYY = IH-1 if CropXX <= CropX then leave if CropYY <= CropY then leave 'CROP' LoadImage CropX CropY CropXX CropYY CropImage = Result 'PROJECT_INFO' CropImage 'WIDTH' /* crop image width */ CIW = RESULT 'PROJECT_INFO' CropImage 'HEIGHT' /* crop image height */ CIH = RESULT if (CIW ~= Xfield)|(CIH ~= Yfield) then do 'RESIZE' CropImage Xfield Yfield NewCropImage = RESULT 'CLOSE' CropImage CropImage = NewCropImage end if Angle ~= 0 then do 'ROTATE' CropImage Angle CalcType RotImage = Result 'CLOSE' CropImage end else RotImage = CropImage if (Angle ~= 0)|(Angle ~= 90)|(Angle ~= 180)|(Angle ~= 270) then do 'RESIZE' RotImage Xfield Yfield 'CENTER' NewRotImage = RESULT 'CLOSE' RotImage RotImage = NewRotImage end 'MARK' RotImage 'PRIMARY' 'MARK' BackImage 'SECONDARY' 'COMPOSITE' CropX CropY 'MIX' 100 NewBackImage = Result 'CLOSE' BackImage BackImage = NewBackImage 'CLOSE' RotImage end /* Xfield */ end /* Yfield */ 'CLOSE' LoadImage OutputImage = BackImage if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'